<?php
    if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Cmmod_article extends MYAD_Model{
        protected $table_name = 'c_article';
        function __construct(){
            parent::__construct();
        }
        function getNameById($id){
            $this->db->where('id',$id);
            $query = $this->db->get($this->table_name);
            return $query->row_array();
        }
        function getAllChild($idParent){
            $this->db->where('parent_id',$idParent);
            $query = $this->db->get($this->table_name);
            return $query->result_array();
        }
        function getNumRowCat($idParent){
            $this->db->where('parent_id',$idParent);
            $query = $this->db->get($this->table_name);
            if($query->num_rows()>0){
                return true;
            }
            else{
                return false;
            }
        }
        function getAllArticleInCategory($idCat){
            $this->db->where('c_id',$idCat);
            $query = $this->db->get('article');
            return $query->num_rows();
        }                 
    }
?>